<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>AbstractController::Layouts::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            AbstractController::Layouts::ClassMethods 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/actionpack/lib/abstract_controller/layouts_rb.html">actionpack/lib/abstract_controller/layouts.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>L</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-layout">layout</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-layout">
            
              <b>layout</b>(layout, conditions = {})
            
            <a href="ClassMethods.html#method-i-layout" name="method-i-layout" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Specify the layout to use for this class.</p>

<p>If the specified layout is a:</p>
<dl class="rdoc-list note-list"><dt><a href="../../String.html">String</a>
<dd>
<p>the <a href="../../String.html">String</a> is the template name</p>
</dd><dt><a href="../../Symbol.html">Symbol</a>
<dd>
<p>call the method specified by the symbol, which will return the template
name</p>
</dd><dt>false
<dd>
<p>There is no layout</p>
</dd><dt>true
<dd>
<p>raise an ArgumentError</p>
</dd><dt>nil
<dd>
<p>Force default layout behavior with inheritance</p>
</dd></dl>

<h4 id="method-i-layout-label-Parameters">Parameters</h4>
<ul><li>
<p><code>layout</code> - The layout to use.</p>
</li></ul>

<h4 id="method-i-layout-label-Options+%28conditions%29">Options (conditions)</h4>
<ul><li>
<p>:only   - A list of actions to apply this layout to.</p>
</li><li>
<p>:except - Apply this layout to all actions but this one.</p>
</li></ul>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-layout_source')" id="l_method-i-layout_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/14c196e5a3f78ea4672b691a09ba60524b31fb73/actionpack/lib/abstract_controller/layouts.rb#L261" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-layout_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/abstract_controller/layouts.rb, line 261</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">layout</span>(<span class="ruby-identifier">layout</span>, <span class="ruby-identifier">conditions</span> = {})
  <span class="ruby-identifier">include</span> <span class="ruby-constant">LayoutConditions</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">conditions</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">conditions</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">conditions</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">v</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_s</span>} }
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">_layout_conditions</span> = <span class="ruby-identifier">conditions</span>

  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">_layout</span> = <span class="ruby-identifier">layout</span>
  <span class="ruby-identifier">_write_layout_method</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    